<template>
	<el-dropdown trigger="click" @command="handleSetSize">
		<div>
			<svg-icon class-name="size-icon" icon-class="size" />
		</div>
		<template #dropdown>
			<el-dropdown-menu slot="dropdown">
				<el-dropdown-item v-for="item of sizeOptions" :key="item.value" :command="item.value"
								  :disabled="size===item.value">
					{{ item.label }}
				</el-dropdown-item>
			</el-dropdown-menu>
		</template>
	</el-dropdown>
</template>

<script lang="ts" setup>
import useAppStore from "@/store/modules/app";
import { computed, ref } from "vue";


const appStore = useAppStore();
const size = computed(() => appStore.size);

const sizeOptions = ref([
	{ label: "较大", value: "large" },
	{ label: "默认", value: "default" },
	{ label: "稍小", value: "small" },
]);

const handleSetSize = (size: string) => {
	appStore.setSize(size);
	window.location.reload();
};


</script>
